import re
from tqdm import tqdm
from lxml import etree
import requests


url_list = [{'猫和素描': 'https://www.vilipix.com/illust/111530188'},
            {'再见夏天': 'https://www.vilipix.com/illust/111536969'},
            {'《基拉皮皮★闪闪发光的2dmv': 'https://www.vilipix.com/illust/111557774'},
            {'岛二郎': 'https://www.vilipix.com/illust/111530284'},
            {'欢迎来到水之国': 'https://www.vilipix.com/illust/111530602'},
            {'鲑鱼萝莉': 'https://www.vilipix.com/illust/111548610'},
            {'WOLF': 'https://www.vilipix.com/illust/111530312'},
            {'個人メモ：股～内腿の立体構造': 'https://www.vilipix.com/illust/111564294'},
            {'RevivedWitch': 'https://www.vilipix.com/illust/111557309'},
            {'惠比寿!!!!': 'https://www.vilipix.com/illust/111557050'},
            {'Magic show!': 'https://www.vilipix.com/illust/111542477'},
            {'黑雀之旅': 'https://www.vilipix.com/illust/111531424'},
            {'小气鬼': 'https://www.vilipix.com/illust/111531457'},
            {"･:*:･ ﾟ '✫, sparkle' ✫ 'ﾟ ･:*:･ ˙": 'https://www.vilipix.com/illust/111548214'},
            {'小米': 'https://www.vilipix.com/illust/111557297'},
            {'伏击准备': 'https://www.vilipix.com/illust/111536696'},
            {'画': 'https://www.vilipix.com/illust/111555825'}, {'IROIRO': 'https://www.vilipix.com/illust/111554091'},
            {'无题': 'https://www.vilipix.com/illust/111557167'}, {'葱': 'https://www.vilipix.com/illust/111582949'},
            {'女仆空君': 'https://www.vilipix.com/illust/111530873'},
            {'【创作BL】生配的赤斯帕常客是男朋友': 'https://www.vilipix.com/illust/111573734'},
            {'里科': 'https://www.vilipix.com/illust/111538676'}, {'无题': 'https://www.vilipix.com/illust/111560688'},
            {'Copy': 'https://www.vilipix.com/illust/111573375'},
            {'汽车角色总结': 'https://www.vilipix.com/illust/111572253'},
            {'9:08pm': 'https://www.vilipix.com/illust/111556575'},
            {'灯笼山路': 'https://www.vilipix.com/illust/111581690'},
            {'9月9日是奇尔诺日': 'https://www.vilipix.com/illust/111558133'},
            {'钟离老师': 'https://www.vilipix.com/illust/111530308'},
            {'基塔桑黑': 'https://www.vilipix.com/illust/111530612'},
            {'广告': 'https://www.vilipix.com/illust/111551977'},
            {'星轨总结3': 'https://www.vilipix.com/illust/111570487'},
            {'No.2137《香蕉》': 'https://www.vilipix.com/illust/111584959'},
            {'尼戈总结': 'https://www.vilipix.com/illust/111553107'},
            {'Satsuki': 'https://www.vilipix.com/illust/111535042'},
            {'无题': 'https://www.vilipix.com/illust/111548738'},
            {'软绵绵的苹果': 'https://www.vilipix.com/illust/111557451'},
            {'0908': 'https://www.vilipix.com/illust/111559126'},
            {'蓝天布丁芭菲': 'https://www.vilipix.com/illust/111571991'},
            {'和我一起战斗吧!': 'https://www.vilipix.com/illust/111540646'},
            {'睡公主送的礼物': 'https://www.vilipix.com/illust/111557005'},
            {'无题': 'https://www.vilipix.com/illust/111572921'},
            {'玻璃娃娃': 'https://www.vilipix.com/illust/111577467'},
            {'好吃啊，萌萌啊W': 'https://www.vilipix.com/illust/111550145'},
            {'粉丝见面会': 'https://www.vilipix.com/illust/111549839'},
            {'Dada': 'https://www.vilipix.com/illust/111542072'},
            {'假面骑士大厦六周年': 'https://www.vilipix.com/illust/111578570'},
            {'原神总结': 'https://www.vilipix.com/illust/111568450'},
            {'博喜多': 'https://www.vilipix.com/illust/111536805'},
            {'蓝莓芝士蛋糕的搭配': 'https://www.vilipix.com/illust/111551628'},
            {'咳嗽游戏 Ⅱ': 'https://www.vilipix.com/illust/111571940'},
            {'【极道师】文豪野犬之福泽谕吉': 'https://www.vilipix.com/illust/111557753'},
            {'刀刃': 'https://www.vilipix.com/illust/111558436'},
            {'瑞士卡比': 'https://www.vilipix.com/illust/111567842'},
            {'女高中生PEBOT(In游乐场)': 'https://www.vilipix.com/illust/111569417'},
            {'娜维娅': 'https://www.vilipix.com/illust/111556748'},
            {'彩虹': 'https://www.vilipix.com/illust/111536781'}, {'尼禄': 'https://www.vilipix.com/illust/111569769'},
            {'限定米克林': 'https://www.vilipix.com/illust/111549303'},
            {'法尔赞': 'https://www.vilipix.com/illust/111556960'},
            {'水神自由纳': 'https://www.vilipix.com/illust/111578098'},
            {'便衣流浪者君': 'https://www.vilipix.com/illust/111580496'},
            {'廖先生': 'https://www.vilipix.com/illust/111536825'}, {'冰': 'https://www.vilipix.com/illust/111579839'},
            {'水晶和企鹅': 'https://www.vilipix.com/illust/111580344'},
            {'和吉拉蒂纳一起。': 'https://www.vilipix.com/illust/111584639'},
            {'嘴平母子': 'https://www.vilipix.com/illust/111561072'},
            {'龙虹': 'https://www.vilipix.com/illust/111536867'},
            {'是节日': 'https://www.vilipix.com/illust/111578102'},
            {'木村拓哉': 'https://www.vilipix.com/illust/111555501'},
            {'无题': 'https://www.vilipix.com/illust/111545226'},
            {'夏季新刊邮购开始了': 'https://www.vilipix.com/illust/111557613'},
            {'无题': 'https://www.vilipix.com/illust/111547938'}, {'广告': 'https://www.vilipix.com/illust/111582494'},
            {'特雷森地区的神奇宝贝和球': 'https://www.vilipix.com/illust/111576110'},
            {'秋天的气息': 'https://www.vilipix.com/illust/111550700'},
            {'&lt;Q&gt;': 'https://www.vilipix.com/illust/111539858'},
            {'✨✨✨✨✨': 'https://www.vilipix.com/illust/111578160'}, {'无题': 'https://www.vilipix.com/illust/111549006'},
            {'草莓蛋糕头发': 'https://www.vilipix.com/illust/111572308'},
            {'夏季日志': 'https://www.vilipix.com/illust/111546977'},
            {'工程师部&hellip; 还可以再拜托你吗&hellip;？': 'https://www.vilipix.com/illust/111548494'},
            {'第12天芭蕾舞演员雷': 'https://www.vilipix.com/illust/111539964'},
            {'这家面包店': 'https://www.vilipix.com/illust/111566669'},
            {'Furina': 'https://www.vilipix.com/illust/111551035'},
            {'老师好啊系列29': 'https://www.vilipix.com/illust/111563251'},
            {'符玄': 'https://www.vilipix.com/illust/111548172'},
            {'柚鸟枣': 'https://www.vilipix.com/illust/111534128'},
            {'天火人立绘表情差分': 'https://www.vilipix.com/illust/111576609'},
            {'发生了无法挽回的事态，灵梦先生请求原谅的魔理沙': 'https://www.vilipix.com/illust/111550784'},
            {'希娜': 'https://www.vilipix.com/illust/111557042'},
            {'不要糖什么的，不要一时的温柔': 'https://www.vilipix.com/illust/111579334'},
            {'柚子': 'https://www.vilipix.com/illust/111545804'},
            {'奥利萨酱': 'https://www.vilipix.com/illust/111557023'},
            {'Twitter总结': 'https://www.vilipix.com/illust/111551763'},
            {'是哈里的天使。': 'https://www.vilipix.com/illust/111534610'},
            {'&hellip;': 'https://www.vilipix.com/illust/111582649'},
            {'Furina': 'https://www.vilipix.com/illust/111548377'},
            {'一喝酒就撒娇的河豚': 'https://www.vilipix.com/illust/111540691'},
            {'Day69娜塔莎': 'https://www.vilipix.com/illust/111546667'},
            {'(工作画) 樱桃子的发布待机画面': 'https://www.vilipix.com/illust/111530741'},
            {'米娜生日快乐 ~♡': 'https://www.vilipix.com/illust/111559032'},
            {'发型': 'https://www.vilipix.com/illust/111583439'},
            {'鲤鱼旗': 'https://www.vilipix.com/illust/111530315'},
            {'基于实验的多葛总公司育儿帕洛': 'https://www.vilipix.com/illust/111561968'},
            {'是生意吗？': 'https://www.vilipix.com/illust/111566564'},
            {'×': 'https://www.vilipix.com/illust/111557225'}, {'水星': 'https://www.vilipix.com/illust/111559367'},
            {'莱蒂先生': 'https://www.vilipix.com/illust/111546816'},
            {'夏天结束的rizean漫画': 'https://www.vilipix.com/illust/111566271'},
            {'无题': 'https://www.vilipix.com/illust/111544770'},
            {'奇尔诺日': 'https://www.vilipix.com/illust/111566089'},
            {'无题': 'https://www.vilipix.com/illust/111582727'}, {'轮回': 'https://www.vilipix.com/illust/111552771'},
            {'【工作画】魔术: 扎扎环《全知》': 'https://www.vilipix.com/illust/111547988'},
            {'鲤鱼旗': 'https://www.vilipix.com/illust/111556996'},
            {'涂鸦': 'https://www.vilipix.com/illust/111553669'}, {'打扮': 'https://www.vilipix.com/illust/111572136'},
            {'20123.9.9铃兰': 'https://www.vilipix.com/illust/111579720'},
            {'鸟居': 'https://www.vilipix.com/illust/111570583'},
            {'孩子和小雷还有夏基': 'https://www.vilipix.com/illust/111549251'},
            {'雅基鸡波卡': 'https://www.vilipix.com/illust/111572569'},
            {'【2434】最后的装 α 【19】': 'https://www.vilipix.com/illust/111532354'},
            {'韦尼斯公园马托梅塔诺': 'https://www.vilipix.com/illust/111557584'},
            {'初音天地开神话': 'https://www.vilipix.com/illust/111583138'},
            {'凤豌诞祭2023': 'https://www.vilipix.com/illust/111579025'},
            {'找到了的威尼斯公园': 'https://www.vilipix.com/illust/111564947'},
            {'Splaton 3发售一周年!!!': 'https://www.vilipix.com/illust/111579900'},
            {'无题': 'https://www.vilipix.com/illust/111554885'},
            {'吃刨冰的CB': 'https://www.vilipix.com/illust/111576855'},
            {'弗兰酱': 'https://www.vilipix.com/illust/111564484'},
            {'小玉': 'https://www.vilipix.com/illust/111582728'},
            {'情薄捏621': 'https://www.vilipix.com/illust/111542580'},
            {'无题': 'https://www.vilipix.com/illust/111578374'},
            {'08新书封面': 'https://www.vilipix.com/illust/111550108'},
            {'弹宝二周年生日会图': 'https://www.vilipix.com/illust/111570451'},
            {'Day70格蕾修': 'https://www.vilipix.com/illust/111575129'},
            {'弗里纳': 'https://www.vilipix.com/illust/111557100'},
            {'星野红宝石': 'https://www.vilipix.com/illust/111534386'},
            {'Take a Break': 'https://www.vilipix.com/illust/111559880'},
            {'奇尔诺': 'https://www.vilipix.com/illust/111567709'},
            {'无题': 'https://www.vilipix.com/illust/111557799'},
            {'好 ~ 累了 ~ 啊 ~': 'https://www.vilipix.com/illust/111548585'},
            {'喉咙': 'https://www.vilipix.com/illust/111557846'},
            {'小李奈特': 'https://www.vilipix.com/illust/111548219'},
            {'喜多。': 'https://www.vilipix.com/illust/111548191'},
            {'蛋包饭': 'https://www.vilipix.com/illust/111574151'},
            {'胡卡酱': 'https://www.vilipix.com/illust/111563541'},
            {'第危机!解决俱乐部': 'https://www.vilipix.com/illust/111577911'},
            {'梅特丽丝': 'https://www.vilipix.com/illust/111581781'},
            {'体操服玛丽': 'https://www.vilipix.com/illust/111558448'},
            {'大胃王的女孩': 'https://www.vilipix.com/illust/111548660'},
            {'Ish the Tyrant': 'https://www.vilipix.com/illust/111535324'},
            {'推特总结': 'https://www.vilipix.com/illust/111579828'},
            {'孤零零': 'https://www.vilipix.com/illust/111568441'},
            {'课题': 'https://www.vilipix.com/illust/111568924'},
            {'鲤鱼旗': 'https://www.vilipix.com/illust/111583869'},
            {'弗里纳': 'https://www.vilipix.com/illust/111567675'},
            {'【私人约稿】不小心看了裙底': 'https://www.vilipix.com/illust/111574187'},
            {'阿默德科6很开心哦!!!!【剧透】': 'https://www.vilipix.com/illust/111572823'},
            {'监护人himari': 'https://www.vilipix.com/illust/111544556'},
            {'斯塔雷拉明信片01': 'https://www.vilipix.com/illust/111559245'},
            {'变得好吃的咒语': 'https://www.vilipix.com/illust/111561856'},
            {'^ ^': 'https://www.vilipix.com/illust/111554191'}, {'利涅萤': 'https://www.vilipix.com/illust/111555409'},
            {'柚子&hellip;&hellip;': 'https://www.vilipix.com/illust/111537467'},
            {'白露吃点什么!': 'https://www.vilipix.com/illust/111541260'},
            {'纳斯普拉纳': 'https://www.vilipix.com/illust/111568945'},
            {'狗系她哭了。': 'https://www.vilipix.com/illust/111571465'},
            {'喜多逃跑的理由': 'https://www.vilipix.com/illust/111581846'},
            {'花芽姐妹生日广告': 'https://www.vilipix.com/illust/111541862'},
            {'胡夫': 'https://www.vilipix.com/illust/111558799'}, {'发现': 'https://www.vilipix.com/illust/111557595'},
            {'Banbaleena': 'https://www.vilipix.com/illust/111571656'},
            {'原神Twilog': 'https://www.vilipix.com/illust/111561926'},
            {'穿衣': 'https://www.vilipix.com/illust/111551004'}, {'草神': 'https://www.vilipix.com/illust/111557080'},
            {'在青草上': 'https://www.vilipix.com/illust/111552988'},
            {'100天ba日更绘画挑战!第33天!': 'https://www.vilipix.com/illust/111555815'},
            {'无题': 'https://www.vilipix.com/illust/111552568'},
            {'白衣天使': 'https://www.vilipix.com/illust/111566143'},
            {'灰和狗': 'https://www.vilipix.com/illust/111553483'},
            {'棘境': 'https://www.vilipix.com/illust/111556127'},
            {'标签强化月总结': 'https://www.vilipix.com/illust/111569853'},
            {'Briar': 'https://www.vilipix.com/illust/111531926'},
            {'尤卡和诺亚': 'https://www.vilipix.com/illust/111584495'},
            {'蓝色玫瑰': 'https://www.vilipix.com/illust/111573422'},
            {'鲤鱼旗': 'https://www.vilipix.com/illust/111560520'},
            {'塞莱斯先生': 'https://www.vilipix.com/illust/111552468'},
            {'蓝色存档 _ 阿罗纳': 'https://www.vilipix.com/illust/111533824'},
            {'The White': 'https://www.vilipix.com/illust/111571192'},
            {'夏尼蒂特总结': 'https://www.vilipix.com/illust/111559166'},
            {'咖啡女仆': 'https://www.vilipix.com/illust/111568414'},
            {'无题': 'https://www.vilipix.com/illust/111549706'},
            {'明年也要隔一会儿。': 'https://www.vilipix.com/illust/111561547'},
            {'努维莱特': 'https://www.vilipix.com/illust/111562438'},
            {'169': 'https://www.vilipix.com/illust/111567039'}, {'对峙': 'https://www.vilipix.com/illust/111582139'},
            {'如果能在梦中见到你': 'https://www.vilipix.com/illust/111557083'},
            {'拉布尤奇诺': 'https://www.vilipix.com/illust/111581893'},
            {'开始的地方': 'https://www.vilipix.com/illust/111555760'},
            {'戌亥子生日应援广告': 'https://www.vilipix.com/illust/111575985'},
            {'充分的休息': 'https://www.vilipix.com/illust/111557217'},
            {'2022冬 ~ 2023夏各种配合': 'https://www.vilipix.com/illust/111557461'},
            {'登场': 'https://www.vilipix.com/illust/111572072'},
            {'Shizuka sweating': 'https://www.vilipix.com/illust/111563370'},
            {'16th': 'https://www.vilipix.com/illust/111554014'},
            {'我家的米克先生，神奇宝贝': 'https://www.vilipix.com/illust/111581025'},
            {'加油小伞小姐3857': 'https://www.vilipix.com/illust/111555970'},
            {'弗里纳': 'https://www.vilipix.com/illust/111570272'},
            {'我女朋友的比弗/售后8': 'https://www.vilipix.com/illust/111557835'},
            {'普通女孩': 'https://www.vilipix.com/illust/111559294'},
            {'超级阿尔蒂梅特可爱': 'https://www.vilipix.com/illust/111572049'},
            {'神里绫华': 'https://www.vilipix.com/illust/111584637'},
            {'旗袍璃奈非常可爱的画': 'https://www.vilipix.com/illust/111554647'},
            {'铃兰': 'https://www.vilipix.com/illust/111553068'}, {'锡兰': 'https://www.vilipix.com/illust/111552465'},
            {'音无小鸟生日快乐!': 'https://www.vilipix.com/illust/111557386'},
            {'符玄酱': 'https://www.vilipix.com/illust/111566780'},
            {'被劫持了': 'https://www.vilipix.com/illust/111575074'},
            {'布鲁阿卡总结': 'https://www.vilipix.com/illust/111555436'},
            {'在电车上只有自己旁边空着的话会很失落吧': 'https://www.vilipix.com/illust/111563043'},
            {'魔法师猫娘化': 'https://www.vilipix.com/illust/111549642'},
            {'生日姐姐': 'https://www.vilipix.com/illust/111558082'},
            {'♡珍珠妈妈生日快乐♡': 'https://www.vilipix.com/illust/111556727'},
            {'ReineMEPtember2023': 'https://www.vilipix.com/illust/111558376'},
            {'MiComet': 'https://www.vilipix.com/illust/111569109'},
            {'爆诞2023!!!': 'https://www.vilipix.com/illust/111582832'},
            {'BUDDY': 'https://www.vilipix.com/illust/111536115'},
            {'16th Anniversary': 'https://www.vilipix.com/illust/111561847'},
            {'小凯莫米七周年': 'https://www.vilipix.com/illust/111565741'},
            {'多亏了你，里奥': 'https://www.vilipix.com/illust/111571441'},
            {'欢迎回来': 'https://www.vilipix.com/illust/111576669'},
            {'天空斯巴鲁先生': 'https://www.vilipix.com/illust/111572322'},
            {'水井酱': 'https://www.vilipix.com/illust/111576671'},
            {'Shenhe wallpaper': 'https://www.vilipix.com/illust/111553477'},
            {'加查德总结1': 'https://www.vilipix.com/illust/111581078'},
            {'鲤鱼旗，鲤鱼旗，鲤鱼旗，鲤鱼旗，鲤鱼旗': 'https://www.vilipix.com/illust/111585911'},
            {'棱镜记录11圆形切割': 'https://www.vilipix.com/illust/111558145'},
            {'数码宝贝与法尔子': 'https://www.vilipix.com/illust/111571864'},
            {'Duel?': 'https://www.vilipix.com/illust/111583389'}, {'比奇': 'https://www.vilipix.com/illust/111550252'},
            {
                '红壳的潘多拉最新25卷 (，,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,': 'https://www.vilipix.com/illust/111537627'},
            {'笨蛋一&hellip;&hellip;': 'https://www.vilipix.com/illust/111575022'},
            {'原神': 'https://www.vilipix.com/illust/111578206'},
            {'继续等待的跟踪狂': 'https://www.vilipix.com/illust/111552063'},
            {'一年后终于决定了姓氏的杨德男子总结': 'https://www.vilipix.com/illust/111580312'},
            {'绮良': 'https://www.vilipix.com/illust/111557974'},
            {'Hu Tao day and night': 'https://www.vilipix.com/illust/111553582'},
            {'[Comm] Corn dog': 'https://www.vilipix.com/illust/111548261'},
            {'我要哭了': 'https://www.vilipix.com/illust/111583473'},
            {'鬼灭LOG': 'https://www.vilipix.com/illust/111558298'},
            {'CHANCE': 'https://www.vilipix.com/illust/111563674'},
            {'无题': 'https://www.vilipix.com/illust/111582736'},
            {'美铃咲夜甜味处': 'https://www.vilipix.com/illust/111566127'},
            {'Rkgk-TenTen': 'https://www.vilipix.com/illust/111567337'},
            {'ReGLOSS': 'https://www.vilipix.com/illust/111570872'},
            {'才羽midori (假) 和&hellip;': 'https://www.vilipix.com/illust/111574471'},
            {'旗袍雏鸟/加湿修正版': 'https://www.vilipix.com/illust/111557139'},
            {'小樱': 'https://www.vilipix.com/illust/111558920'}, {'✌️✌️': 'https://www.vilipix.com/illust/111578301'},
            {'Comfort the Archon': 'https://www.vilipix.com/illust/111580973'},
            {'弗里纳': 'https://www.vilipix.com/illust/111546220'},
            {'小熊维尼!': 'https://www.vilipix.com/illust/111568656'},
            {'如果知道伊瓜苏被621对待的话，那边也会憧憬的吧': 'https://www.vilipix.com/illust/111570700'}]


def get_html_data(name, url, my_headers, tag_list_all):
    """
    得到标签数据
    :param name: 图片名
    :param url: 图片链接
    :param my_headers: 头
    :param tag_list_all: 存放图片tag的列表
    :return:None
    """
    tag_one_all = []
    reqs = requests.get(url, headers=my_headers)
    reqs_content = reqs.text
    html_data = etree.HTML(reqs_content)
    tag_origin = html_data.xpath(
        'count(//*[@id="__layout"]/div/div[1]/div[2]/div/main/section[2]/div/div/div[2]/ul/li)')
    count = int(tag_origin)
    for i in range(1, count + 1):
        tag = html_data.xpath(f'//*[@id="__layout"]/div/div[1]/div[2]/div/main/section[2]/div/div/div[2]/ul/li[{i}]/a')[
            0].text
        illegal_chars = r'[<>:"/\\,|# ･✫ﾟ˙?*\x00-\x1F]'  # 排除非法字符的正则
        tag_clean = re.sub(illegal_chars, '', tag)
        tag_one_all.append(tag_clean)
    name_tag = {name: tag_one_all}
    tag_list_all.append(name_tag)
    return  None


def get_all_tag(list_url, my_headers, list_all):
    """
    启动项
    :param list_url: 完整的链接列表
    :param my_headers: 头
    :param list_all: 存放标签的列表
    :return:None
    """
    for data in tqdm(list_url, '请等待'):
        name = list(data.keys())[0]
        url = list(data.values())[0]
        get_html_data(name, url, my_headers, list_all)
    return None


if __name__ == "__main__":
    url_front = 'https://www.vilipix.com/illust/'
    headers = {
        'User-Agent':
            'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.69',
        'Cookie':
            'auth.strategy=local; Hm_lvt_7246eb56b79171a6fe5284a8bf523aa0=1694076593,1694081519,1694141021,1694154244; Hm_lpvt_7246eb56b79171a6fe5284a8bf523aa0=1694154244'
    }
    tag_name_data = []
    get_all_tag(url_list, headers, tag_name_data)
    print(tag_name_data)
